﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using Microsoft.SharePoint.Administration;

namespace SharePointCommander.Model.TreeView
{
    public class SCServiceInstance : SCTreeViewItem<SPServiceInstance>
    {
        public SCServiceInstance(SCTreeViewItem parent, SPServiceInstance serviceInstance)
            : base(parent, serviceInstance)
        {
            Header = serviceInstance.TypeName;
            Expanded += new System.Windows.RoutedEventHandler(SCServiceInstance_Expanded);
            ItemsSource = new object[] { null };
        }

        void SCServiceInstance_Expanded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!ItemsSource.OfType<SCProperties>().Any())
            {
                ItemsSource = new[] { new SCProperties(this, SPObject.Properties) as TreeViewItem };
            }
        }
    }
}
